package cn.itcast.hotel.controller;

import cn.itcast.hotel.pojo.HotelDoc;
import cn.itcast.hotel.pojo.Result;
import cn.itcast.hotel.pojo.SearchDto;
import cn.itcast.hotel.service.HotelSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hotel")
public class SearchController {
    @Autowired
    private HotelSearchService searchService;
    @PostMapping ("/list")
    public Result<HotelDoc> searchAll(@RequestBody SearchDto searchDto) throws IOException {

        return searchService.searchAll(searchDto);
    }

    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody SearchDto searchDto) throws IOException {
        return searchService.filters(searchDto);
    }


    @GetMapping("suggestion")
    public List<String> getSuggestions(@RequestParam("key") String key) throws IOException {
        return searchService.getSuggestions(key);
    }
}
